import 'package:flutter/material.dart';

import '../../YColors.dart';
import '../MyRefreshTest.dart';
import '../order/TodoTask.dart';
import '../order/HistoryTask.dart';
import '../order/FinishTask.dart';
import '../order/LaunchTask.dart';

class OrderPage extends StatefulWidget {
  OrderPage({Key key}) : super(key: key);

  _OrderPageState createState() => _OrderPageState();
}

class _OrderPageState extends State<OrderPage>
    with SingleTickerProviderStateMixin {
  TabController _tabController;

  @override
  void initState() {
    // 生命周期函数
    // TODO: implement initState
    super.initState();
    _tabController = new TabController(
      vsync: this,
      length: 6,
    );

    /*
    * 监听状态的变化
    * */
    _tabController.addListener(() {
      print('点击了${_tabController.index}');
//      print(_tabController.index);
//      setState(() {
//
//      });
    });
  }

  @override
  void dispose() {
    // 生命周期函数
    // TODO: implement dispose
    super.dispose();
    print('dispose');
    _tabController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 4,
      child: Scaffold(
        appBar: AppBar(
          backgroundColor: Color(0xffffffff),
          title: Row(
            children: <Widget>[
              Expanded(
                child: TabBar(
                  isScrollable:true,  // 可以滑动
                  indicatorColor: Colors.green, // 指示器验收
                  labelColor: Colors.green, // 选中 label 颜色
                  unselectedLabelColor: YColors.b, // 选中 label 颜色
//            指示器大小计算方式，TabBarIndicatorSize.label 跟文
//           字等宽,TabBarIndicatorSize.tab 跟每个 tab 等宽
//                  indicatorSize: TabBarIndicatorSize.label,

                  tabs: <Widget>[
                    Tab(
                      text: "待办任务",
                    ),
                    Tab(
                      text: "历史任务",
                    ),
                    Tab(
                      text: "办结任务",
                    ),
                    Tab(
                      text: "我发起的流程",
                    ),
                  ],
                ),
              )
            ],
          ),
          centerTitle: true,
        ),
        body: TabBarView(
          children: <Widget>[
            ListView(
              children: <Widget>[
                InkWell(
                  child: Container(
                    padding: EdgeInsets.fromLTRB(20, 30, 20, 20),
                    child: Text("去查看审核页面"),
                  ),
                  onTap: (){
                    print("去查看审核页面");
                    Navigator.pushNamed(context, "/VerifyPage");
                  },
                ),
                InkWell(
                  child: Container(
                    padding: EdgeInsets.fromLTRB(20, 5, 20, 20),
                    child: Text("查看文档"),
                  ),
                  onTap: () {
                    print("去查看文档去吧");
                    Navigator.pushNamed(context, "/Document");
                  },
                ),

                InkWell(
                  child: Container(
                    padding: EdgeInsets.fromLTRB(20, 5, 20, 20),
                    child: Text("动画的类"),
                  ),
                  onTap: () {
                    print("动画的类");
                    Navigator.pushNamed(context, "/RouterAnimation");
                  },
                ),

                InkWell(
                  child: Container(
                    padding: EdgeInsets.fromLTRB(20, 5, 20, 20),
                    child: Text("动画缩放功能"),
                  ),
                  onTap: () {
                    print("动画缩放功能");
                    Navigator.pushNamed(context, "/ScalePage");
                  },
                ),

                InkWell(
                  child: Container(
                    padding: EdgeInsets.fromLTRB(20, 5, 20, 20),
                    child: Text("去使用封装的头布局的类"),
                  ),
                  onTap: () {
                    print("去使用封装的头布局的类");
                    Navigator.pushNamed(context, "/HeadTest");
                  },
                ),


                RaisedButton(
                    child: Text("去登录"),
                    onPressed: () {
                      print("去登录");
                      Navigator.pushNamed(context, "/LoginCode");
                    }),
              ],
            ),
            TodoTaskPage(), // 写待办问任务的类
            HistoryTaskPage(),
            FinishTaskPage(),
//            LaunchTaskPage(),
//            Container(
////              width: 120,
////              height: 50,
////              color: Colors.green,
//              child: ListView(
//                children: <Widget>[
//                  Text("待审核的订单"),
//                ],
//              ),
//            ),
//            MyRefreshPage(),
          ],
        ),
      ),
    );
  }
}
